Description:
RVNC checks that values returned by
non-void methods
are used correctly.
A warning message is produced when a
method returning a non-void type
is called at least once,
but its return value is never used. For methods that are not used,
a MNU (member is not used) warning is produced instead. Method overriding is considered,
i.e., it is assumed that if a concrete method is called, all methods from the derived classes
that override it can be called instead of this method.
Another warning message is produced when values returned by a method are used by some callers, but are ignored by others. For methods that return error codes, ignoring the returned value may make error detection and handling more difficult.
Incorrect:
public class Buffer {
private bool Extend(int size) {
...
}
public void Add(object obj) {
...
Extend(delta);
...
}
}
Correct:
public class Buffer {
private bool Extend(int size) {
...
}
public void Add(object obj) {
...
if (Extend(delta)) {
...
}
}
}